'use strict'
/**
 * CookieUtil
 * Cookie缓存工具类
 * 你是一段成熟的代码，要学会自己改bug  ----我是小尾巴
 */

import * as Cookies from 'js-cookie'

import {cookieParam} from './config/cookie.config.js'

export {
  cookieParam
}

/**
 * 获取cookie值
 * @param key
 * @returns {*}
 */
export function getCookieItem (key) {
  return Cookies.get(key)
}

/**
 * 设置cookie
 * @param key
 * @param value
 * @param params
 */
export function setCookieItem (key, value, params = {}) {
  Cookies.set(key, value, params)
}

/**
 * 移除cookie
 * @param key
 * @param param
 */
export function removeCookieItem (key, param) {
  if (param) {
    Cookies.remove(key, param)
  } else {
    Cookies.remove(key)
  }
}

/**
 * 获取cookie的json数据
 * @param key
 * @returns {*}
 */
export function cookieData (key) {
  if (key) {
    return Cookies.getJSON(key)
  } else {
    return Cookies.getJSON()
  }
}
